/***************************************************************************
 *   Copyleft 2008-2009 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __COLOR_H__
#define __COLOR_H__

#include "../../Utils/vString.h"
#include "../../Macros/vMemoryMacros.h"

namespace Vendetta {
	class vColor {
	public:
		union {
			struct {
				vReal Values[4];
			};
			struct {
				vReal R;
				vReal G;
				vReal B;
				vReal A;
			};
		};

		/**************************************************************
		* Constructors                                                *
		***************************************************************/
		vColor(): R(0.0f), G(0.0f), B(0.0f), A(1.0f) { }
		vColor(vReal fR, vReal fG, vReal fB): R(fR), G(fG), B(fB), A(1.0f) { }
		vColor(vReal fR, vReal fG, vReal fB, vReal fA): R(fR), G(fG), B(fB), A(fA) { }
		vColor(const vColor& color);

		/**************************************************************
		* Operators                                                   *
		***************************************************************/
		vColor& operator+=(const vColor& colorB);
		vColor& operator-=(const vColor& colorB);
		vColor operator-() const;
		vColor& operator*=(const vColor& colorB);
		vColor& operator*=(const vReal fFactor);
		vColor& operator=(const vColor& colorB);
		vBool operator == (const vColor& colorB) const;
		vColor operator*(const vReal fFactor);
		vColor operator*(const vColor& colorB);
		vColor operator+(const vColor& colorB);
		vColor operator-(const vColor& colorB);

		/**************************************************************
		* Helpful functions                                           *
		***************************************************************/
		vVoid ClipComponents();
		vVoid PositiveClipComponents();
		static vWinColor ToWinColor(const vColor& color);
		static vColor FromWinColor(const vWinColor& color);
		static vColor AlphaBlend(vReal alpha, vColor &c1, vColor &c2);

		static const vColor Red;
		static const vColor Green;
		static const vColor Blue;
		static const vColor White;
		static const vColor Black;
	};


	#define RED					(vColor::Red())
	#define GREEN				(vColor::Green())
	#define BLUE				(vColor::Blue())
	#define WHITE				(vColor::White())
	#define BLACK				(vColor::Black())
}


#endif //__COLOR_H__